#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#define endl "\n"
using namespace std;
int n, a[2010], y=0,yy=0,yyy=0;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int l = 1, r = n;
	while (l < r)
	{	
		y =y+ (a[l] + a[l + 1]) % 3;
		l =l+ 2;
	}
	l = 1, r = n;
	while (l < r)
	{
		yy = yy + (a[r] + a[r - 1])%3;
		r = r - 2;
	}
	l = 1, r = n;
	while (l < r)
	{
		yyy = yyy + (a[l] + a[r])%3;
		l = l + 1;
		r = r - 1;
	}
	cout << max({ y,yy,yyy }) << endl;
	return 0;
}